import request from '@/utils/request'

export interface LoginData {
  userAccount: string
  userPassword: string
}

export interface RegisterData {
  userAccount: string
  userPassword: string
  checkPassword: string
  email: string
  cpacha: string
}

export interface UserInfo {
  id: number
  username: string
  phone?: string
  email?: string
  createTime?: string
  status?: number
}

export const login = (data: LoginData) => {
  return request({
    url: '/user/login',
    method: 'post',
    data,
  })
}

export const register = (data: RegisterData) => {
  return request({
    url: '/user/register',
    method: 'post',
    data,
  })
}

export const getUserInfo = () => {
  return request({
    url: '/user/info',
    method: 'get',
  })
}

export const sendVerifyCode = (email: string) => {
  return request({
    url: '/captcha',
    method: 'post',
    data: { email },
  })
}
